﻿<%@ Page Title="" Language="C#" MasterPageFile="~/website/Site1.Master" AutoEventWireup="true" %>
<%@ Import Namespace="ChicagoDealsN" %>

<script language = "c#" Runat="Server">
    void Page_Load()
    {
        
    }

    private int getId()
    {
        return (Session["Userdet"] as DataUser).User_Id; ;
    }
    
    void Submit_Newdeal_Click(Object s, EventArgs e)
    {
        BizDeals bd = new BizDeals();
        string imgPath="";
        if (FileUploadControl.HasFile)
        {
            string filename = System.IO.Path.GetFileName(FileUploadControl.FileName);
            FileUploadControl.SaveAs(Server.MapPath("~/static/img/") + filename);
            imgPath = "/static/img/"+filename;
            confirmation.Text = "Your request to new deal has been posted!";
        }

        bd.BLCreateDeal(txtTitle.Text, imgPath, txtCompanyName.Text, txtDealDescription.Text, float.Parse(txtOrgPrice.Text), float.Parse(txtDealPrice.Text), calStartDate.Text, calEndDate.Text, Convert.ToInt32(txtQty.Text), getId());

        //txtId.Text = dr["Deal_Id"].ToString();
        txtTitle.Text = "";
        txtCompanyName.Text = "";
        //FileUploadControl = dr["Img_Path"].ToString(); 
       // dealImg.ImageUrl = "~" + dr["Img_Path"].ToString();
        txtDealDescription.Text = "";
        txtOrgPrice.Text = "";
        txtDealPrice.Text = "";
        calStartDate.Text = "";
        calEndDate.Text = "";
        txtQty.Text = "";
    }

</script>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

<div id="conirmation-container">
       <asp:Label id="confirmation" runat="server" />
       <br/>
</div>

   <table>
    <tr>
        <td>Title:</td>
        <td><asp:TextBox runat="server" ID="txtTitle" /></td>
    </tr>
    <tr>
        <td>Image:</td>
        <td><asp:FileUpload id="FileUploadControl" runat="server" /></td>
    </tr>
    <tr>
        <td>Company Name:</td>
        <td><asp:TextBox runat="server" ID="txtCompanyName" /></td>
    </tr>
    <tr>
        <td>Description: </td>
        <td><asp:TextBox runat="server" ID="txtDealDescription" /></td>
    </tr>
    <tr>
        <td>Original Price:</td>
        <td><asp:TextBox runat="server" ID="txtOrgPrice" /></td>
    </tr>
    <tr>
        <td>Deal Price:</td>
        <td><asp:TextBox runat="server" ID="txtDealPrice" /></td>
    </tr>
    <tr>
        <td>Start Date:</td>
        <td><asp:TextBox runat="server" ID="calStartDate" /></td>
    </tr>
    <tr>
        <td>End Date:</td>
        <td><asp:TextBox runat="server" ID="calEndDate" /></td>
    </tr>
    <tr>
        <td>Quantity:</td>
        <td><asp:TextBox runat="server" ID="txtQty" /></td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td><asp:Button runat="server" ID="submit_newdeal" OnClick="Submit_Newdeal_Click" text="Submit"/></td>
    </tr>
   </table>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
</asp:Content>

